<extend name="./Application/Home/View/Public/Base/common.html" />
<block name="title">点播服务</block>
<block name="breadcrumb">
	点播服务
	<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
</block>
<block name="body">
	<style>
		.mk-blue{
			color: #00a2d4;
		}

		.mk-hasbtn{
			margin-top: 45px;
			position: relative;
		}

		.page-nation-botton,.page-nation-up,.page-nation-down{
			width: 30px;
			height: 30px;
			border: 1px solid #dcdcdc;
			display: inline-block;
			margin-top: 2px;
			text-align: center;
			line-height: 30px;
			border-radius: 3px;
			cursor: pointer;
		}

		.page-nation-up,.page-nation-down{
			width: 50px;
		}

		#pageNation{
			height: 35px;
			position: absolute;
			right: 0px;
			bottom: -50px;
		}


		.table th,.table td{
			font-size: 13px;
		}

		.table th{
			background: #E0EAF6 !important;
		}

		.button-img{
			width: 18px;
			margin-bottom: 2px;
			margin-right: 5px;
		}

        .redcolor{
            color: red;
        }

        .greencolor{
            color: green;
        }

		.search{
			width: 200px;
			position: absolute;
			left:20px;
		}
		.search-button{
			position: absolute;
			left:240px;
		}
	</style>
	<article class="cl pd-20" style="position: relative;">
		<div id="kkk" style="width:90%;margin-top: -5px;text-align: center;">
			<input type="text" class="input-text radius size-M search"  placeholder="请输入点播服务器名称">
			<span class="l r search-button" >
                    <a href="javascript:;" onclick="searchList()" class="btn radius" style="background: #F5F8F9;"><img  class="button-img" src="__HUI__/images/search.png">搜索</a>
			</span>
			<table class="table  table-hover table-bg table-sort">
              <span class="l r" style="position: absolute;left: 335px;">
                    <a href="javascript:;" onclick="add()" class="btn radius" style="background: #F5F8F9;"><img  class="button-img" src="__HUI__/images/t01.png">添加</a>
              </span>
              <span class="l r" style="position: absolute;left: 430px;">
                  <a href="javascript:;" onclick="delAll()" style="background: #F5F8F9;" class="btn radius"><img class="button-img" src="__HUI__/images/t03.png">删除</a>
              </span>
			</table>
		</div>
		<div class="mt-20 mk-hasbtn">
			<table class="table table-border table-bordered table-bg table-hover table-sort">
				<thead>
				<tr class="text-c">
					<th width="3%"><input type="checkbox" name="" value=""></th>
					<th width="15%">点播服务器名</th>
					<th width="15%">ip地址</th>
					<th width="15%">端口</th>
					<th width="15%">载体ID</th>
					<th width="15%">存储路径</th>
                    <th width="15%">状态</th>
					<th width="7%">操作</th>
				</tr>
				</thead>
				<tbody>
                <volist name="array['vodsvr']" id = 'row' key="k">
                    <tr class="text-c">
                        <td><input type="checkbox" value="{$row['id']}" name=""></td>
                        <td>{$row['vodsvrname']}</td>
                        <td>{$row['ip']}</td>
                        <td>{$row['port']}</td>
                        <td>{$row['vodsvrstoragerid']}</td>
                        <td>{$row['vodsvrpath']}</td>
                        <if condition="$row['status'] eq 0">
                            <td class="redcolor">
                                不在线
                            </td>
                            <elseif condition="$row['status'] eq 1"/>
                            <td class="greencolor">
                                在线
                            </td>
                        </if>

                        <td class="f-14 td-manage"><a style="text-decoration:none" class="mk-blue" onClick="modify('{$row[id]}')" href="javascript:;" title="修改">修改</a></td>
                    </tr>
                </volist>
				</tbody>
				<div id="pageNation">
					<if condition="($pagesum gt 1) AND ($page neq 1)">
						<span class="page-nation-up" onclick="pageUp();">上一页</span>
					</if>
					<if condition="$pagesum gt 1">
						<for start="0" end="$pagesum">
							<span class="page-nation-botton" onclick="pageGo({$i+1});">{$i+1}</span>
						</for>
					</if>
					<if condition="($pagesum gt 1) AND ($pagesum gt $page)">
						<span class="page-nation-down" onclick="pageDown();">下一页</span>
					</if>
					<if condition="$pagesum gt 1">
						<span style="display: inline-block;width: 50px;border: 1px solid #cccccc;text-align: center;border-radius: 3px;background: rgb(219, 247, 253);">共{$pagesum}页</span>
					</if>
				</div>
			</table>
		</div>
	</article>
	<script type="text/javascript">
		var page = 1;
		if({$page}){
			page = {$page};
		}
		setTimeout(function(){
			$(".page-nation-botton").each(function(){
				if($(this).text() == page){
					$(this).css("background","#DBF7FD");
				}else{
					$(this).css("background","white");
				}
			})
		},200);

		var add = function(){
			layer.open({
				type: 2,
				area: ['500px', '550px'],
				fixed: true,
				content: "{:U('Home/index/addVodSvr')}"
			});
		}

		var modify = function(id){
			layer.open({
				type: 2,
				area: ['500px', '550px'],
				fixed: true,
				content: "{:U('Home/index/modifyVodSvr')}"+"?vodid="+id
			});
		}
		var delAll = function(){
			layer.confirm('确认要全部删除吗？',{icon:3},function(){
				$("table input").each(function(){
					if($(this)[0].checked == true){
						var pop = $(this)[0].value;
						$.ajax({
							type : "POST",
							url : "{:U('Home/Index/delVodSvr')}",
							data: {vodsvrid:pop},
							dataType : "json",
							success : function (data) {
							}
						});
					}
				});
				layer.msg('已删除!',{icon:1,time:500});
				setTimeout(function(){
					window.location.href=window.location.href;
				},800);
			});
		}

		var searchList = function(){
			var msg = $(".search").val();
			if(msg){
				window.location.href = "{:U('Home/Index/index')}"+"?vodsvrname="+msg;
			}else{
				layer.msg('请输入点播服务器名', {
					icon: 2,
					time: 1000
				});
			}

		}


		//上一页
		function pageUp() {
			var num;
			if(page==1){
				num = page;
			}else{
				num = page-1;
			}
			window.location.href = "{:U('Home/Index/index')}"+"?page="+num;
		}

		//下一页
		function pageDown(){
			var num;
			if({$pagesum} == page){
				num = page;
			}else{
				num = page+1;
			}
			window.location.href = "{:U('Home/Index/index')}"+"?page="+num;
		}

		//指定页
		function pageGo(num) {
			page = num;
			window.location.href = "{:U('Home/Index/index')}"+"?page="+num;
		}


	</script>
</block>